<template>
  <basic-container>
    <promoters-list
      v-show="promotersType === 'list'"
      @addNew="addNew"
      ref="promotersListRef"
      @editPromoters="editPromoters"
    ></promoters-list>
    <promoters-add-edit
      v-if="promotersType !== 'list'"
      @back="handleBack"
      :promotersType="promotersType"
      :promotersForm="promotersForm"
    />
  </basic-container>
</template>
<script>
import promotersList from "@/views/marketing-management/promoters-list.vue";
import promotersAddEdit from "@/views/marketing-management/promoters-add-edit.vue";
export default {
  data() {
    return {
      promotersType: "list",
      promotersForm: {},
    };
  },

  components: {
    promotersList,
    promotersAddEdit,
  },
  methods: {
    handleBack(refresh) {
      this.promotersType = "list";
      if (refresh) {
        this.$refs.promotersListRef.onLoad({ current: 1, size: 10 });
      }
    },
    addNew() {
      this.promotersType = "add";
    },
    editPromoters(row) {
      this.promotersType = "edit";
      this.promotersForm = row;
    },
  },
};
</script>
